﻿using System;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using EIA.SLClient.Utility.Converters;

namespace EIA.SLClient.ProjectManage.Converters
{
    public class StaffId2NameConverter : GenericConverter<int?, string>
    {
        public StaffId2NameConverter() :
            base((s, p) =>
            {
                try
                {
                    if (!s.HasValue) return "";
                    var c = ListsResource.Instance.StaffCollection.FirstOrDefault((i) => { return i.StfId == s; });
                    return c == null ? s.ToString() : c.StfName;
                }
                catch (System.Exception ex)
                {
                    return s.HasValue ? s.ToString() : "";
                }


            })
        {
        }

    }
}
